package cn.tedu.ivos.geofence.controller;

import cn.tedu.ivos.base.response.JsonResult;
import cn.tedu.ivos.geofence.pojo.dto.GeofenceQuery;
import cn.tedu.ivos.geofence.pojo.dto.GeofenceSaveParam;
import cn.tedu.ivos.geofence.pojo.vo.GeofenceVO;
import cn.tedu.ivos.geofence.service.GeofenceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/v1/geofence")
public class GeofenceController {
    @Autowired
    private GeofenceService geofenceService;

    @GetMapping("/select")
    public JsonResult selectGeofence(GeofenceQuery geofenceQuery){
        List<GeofenceVO> geofenceVOS = geofenceService.selectGeofence(geofenceQuery);
        return JsonResult.ok(geofenceVOS);
    }

    /**
     * 新建围栏信息
     * @param geofenceSaveParam
     * @return
     */
    @PostMapping("/save")
    public JsonResult save(GeofenceSaveParam geofenceSaveParam){
        geofenceService.saveGeofence(geofenceSaveParam);
        return JsonResult.ok();
    }
    @PostMapping("/delete/{id}")
    public JsonResult save(@PathVariable Long id){
        geofenceService.deleteGeofence(id);
        return JsonResult.ok();
    }
}
